feat(inbox): show live PR status on pull request list cards#2695
Merged
Conversation
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
packages/core/src/git/router-schemas.ts:363-364
The `state` field is typed as `z.string()`, which means Zod will accept any string at runtime. The badge logic elsewhere does an exact comparison against `"closed"` (and implicitly relies on `"open"` / `"merged"` being the only other values). An unexpected string from the GraphQL layer — say, a future GitHub enum value or a data bug — silently falls through to the green "open" styling. A `z.enum` narrows the type, enables exhaustive matching, and catches bad values at the boundary.
```suggestion
/** Lowercased GitHub PR state. */
state: z.enum(["open", "closed", "merged"]),
```
### Issue 2 of 2
packages/workspace-server/src/services/git/schemas.ts:319-320
Same concern as in `@posthog/core/git/router-schemas` — the mirrored copy should also use `z.enum` so any unexpected GraphQL value is rejected at the server boundary before it reaches the client.
```suggestion
/** Lowercased GitHub PR state. */
state: z.enum(["open", "closed", "merged"]),
```
Reviews (1): Last reviewed commit: "feat(inbox): show live PR status on pull..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6888cbd727
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Extend the batched diff-stats GraphQL request to also fetch each PR's state/isDraft, so list cards render live status (open/draft/merged/closed) with no extra API calls. ReportImplementationPrLink now reads status from the batch context when present and only falls back to the per-PR usePrDetails query on the standalone detail view.
- Narrow PR state to a z.enum(['open','closed','merged']) in both schema copies so unexpected GraphQL values are caught at the boundary; the workspace-server maps GitHub's enum with a safe 'open' fallback. - Harden ReportImplementationPrLink: validate the URL via parsePrUrl (no unvalidated external link), render nothing for unknown/unresolved state instead of a misleading green 'open', and guard the tooltip with isLoading. - Stack the status badge above the line-diff on the card to use horizontal space more efficiently.
6888cbd to
23c9e0d
Compare
The Pulls list reads status from the batched getPrDiffStatsBatch query, which usePrActions wasn't invalidating — only the per-PR getPrDetailsByUrl cache. Invalidate the batch on a successful PR action so the list badge doesn't show stale status until the 5-min cache expires.
Gilbert09
added a commit
that referenced
this pull request
Jun 16, 2026
…ort #2695, #2694) Inbox signal reports that have an `implementation_pr_url` now render a live PR-status badge (open / merged / closed / draft) on the report list rows, the tinder card, and the report detail screen — reusing the existing `usePrStatus` hook and `PrStatusBadge` component from the tasks feature. The badge only renders for a canonical GitHub PR URL and renders nothing while the state is loading or unresolvable (private repo / 404 / unparseable), rather than showing a misleading default "open" badge. This is gated by a new `hideWhenUnresolved` prop on `PrStatusBadge`; the existing task-header usage keeps its always-tappable neutral badge. A `size="sm"` variant keeps the badge compact on dense list rows. Ports the desktop behavior from #2695 (list cards) and #2694 (detail) to the mobile app. The desktop GraphQL batching is intentionally not ported; mobile relies on react-query caching of the public GitHub REST API. Generated-By: PostHog Code Task-Id: ba8e678f-1c24-4c21-abe3-5dc204adec1a
Gilbert09
added a commit
that referenced
this pull request
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #2694 (merged), which added a live PR-status badge to the pull request detail view. This brings that status to the list cards in the Pulls tab, plus addresses review feedback from both PRs.
The naive approach (a
usePrDetailscall per card) would be an N+1: onegh apiREST call per visible PR, and GitHub is rate-limited.Changes
Live status on list cards (no extra API calls)
workspace-server— thegetPrDiffStatsBatchGraphQL query already fetches diff stats for every visible PR in one request. Addedstate isDraftto the same fragment and normalised GitHub'sOPEN | CLOSED | MERGEDenum into the{ state, merged, draft }shape the badge expects. Zero additional requests.core+workspace-serverschemas — addedstate/merged/drafttoprDiffStatsSchema(both copies).ReportImplementationPrLink— now reads status from the surroundingPrDiffStatsBatchContextwhen present (list), falling back to the per-PRusePrDetailsquery only when there's no batch provider (detail view) — mirroring howPrDiffStatsalready works.PullRequestCard— renders the status badge, stacked above the line-diff to use horizontal space efficiently.Review feedback addressed (from #2694 + #2695 bots)
getPrDetailsByUrlreturns{ state: "unknown" }on failure; the badge now renders nothing for any unresolved state instead of a misleading green "open".parsePrUrl(the same gate as "Open in GitHub") and renders nothing for non-canonical/unsafe URLs, so it never exposes an unvalidated external link.isLoadingso it doesn't show default values while pending.stateasz.enum(Greptile) —stateis nowz.enum(["open","closed","merged"])in both schema copies; the server maps GitHub's GraphQL enum with a safe"open"fallback so an unexpected value can't fail validation for the whole batch.How did you test this?
biome check+ typecheck clean across@posthog/core,@posthog/workspace-server, and@posthog/ui.workspace-server, so the app needs a full restart (not just renderer HMR) to serve the new GraphQL fields.Notes
mainand folds in the feat(inbox): show live PR status on pull request detail #2694 review fixes too.Automatic notifications